package com.lap.auth.application.authorization.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import java.util.ArrayList;
import java.util.List;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

@Data
@Schema(description = "菜单展示数据传输返回")
public class MenuViewDto {

  @Schema(description = "菜单唯一标识")
  private Integer id;

  @Schema(description = "菜单父标识")
  private Integer pid;

  @Schema(description = "菜单路径")
  private String path;

  @Schema(description = "菜单名称")
  private String name;

  @Schema(description = "菜单组件")
  private String component;

  @Schema(description = "菜单跳转")
  private String redirect;

  @Schema(description = "菜单跳转地址")
  private String link;

  @Schema(description = "菜单排序")
  private Integer sortOrder;

  @Schema(description = "菜单元件")
  private MetaViewDTO meta;

  @Setter
  @Getter(AccessLevel.NONE)
  @Schema(description = "子菜单")
  private List<MenuViewDto> children;

  public List<MenuViewDto> getChildren() {
    if (children == null) {
      children = new ArrayList<>();
    }
    return children;
  }

  @Schema(description = "元件数据传输")
  public static class MetaViewDTO {

    @Getter
    @Setter
    @Schema(description = "国际化编码")
    private String title;

    @Getter
    @Setter
    @Schema(description = "图标")
    private String icon;

    @Schema(description = "是否隐藏")
    private boolean isHide;

    @Schema(description = "是否缓存")
    private boolean isKeepAlive;

    @Schema(description = "是否固定tag")
    private boolean isAffix;

    @Schema(description = "是否外链")
    private boolean isIframe;

    public boolean getIsHide() {
      return isHide;
    }

    public void setIsHide(boolean hide) {
      this.isHide = hide;
    }

    public boolean getIsKeepAlive() {
      return isKeepAlive;
    }

    public void setIsKeepAlive(boolean keepAlive) {
      this.isKeepAlive = keepAlive;
    }

    public boolean getIsAffix() {
      return isAffix;
    }

    public void setIsAffix(boolean affix) {
      this.isAffix = affix;
    }

    public boolean getIsIframe() {
      return isIframe;
    }

    public void setIsIframe(boolean iframe) {
      this.isIframe = iframe;
    }
  }
}
